package com.haoshuang.zhouzhoubang.ui.page.study.child

import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ItemStudyArticleListBinding
import com.haoshuang.zhouzhoubang.model.bean.TrainArticleBean
import com.mufeng.libs.base.BaseBindingHolder
import com.mufeng.libs.base.BaseBindingQuickAdapter
import com.mufeng.libs.utils.view.load
import com.mufeng.libs.utils.view.visibleOrGone


/**
 * 
 */
class StudyArticleListAdapter(data: MutableList<TrainArticleBean>) : BaseBindingQuickAdapter<TrainArticleBean, ItemStudyArticleListBinding>(data) {

    var type_id = ""

    override fun onBindViewHolder(holder: BaseBindingHolder, position: Int, item: TrainArticleBean?) {
        holder.getViewBinding<ItemStudyArticleListBinding>().apply {
            llQualification.visibleOrGone(type_id == "9")
            llTrain.visibleOrGone(type_id != "9")

            if (type_id == "9") {
                val is_order_eligibility = item?.is_order_eligibility
                tvTitle.text = item?.title
                if (is_order_eligibility == 1) {
                    // 开始通过
                    tvStatus.isSelected = true
                    tvStatus.text = "已完成"
                    tvStudy.text = "复习"
                } else {
                    // 考试未通过
                    tvStatus.isSelected = false
                    tvStatus.text = "未完成"
                    tvStudy.text = "学习"
                }
            } else {
                tvStudyTitle.text = item?.title
                tvDes.text = item?.des
                tvCreateTime.text = item?.create_time
                ivHeadPic.load(
                    item?.headpic,
                    placeholder = R.mipmap.default_image,
                    error = R.mipmap.default_image,
                )
            }
        }
    }

}